<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/10/17 0017
  Time: 20:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/meta.jsp"%>
<meta http-equiv="Content-Type" content="textml; charset=UTF-8">
<html>
<head>
    <title>Title</title>
</head>
<body>
<form id="deptInfoForm">
    <input type="hidden" value="${dept.id}" id="deptInfo_id" name="id"/>
    <table cellpadding="0" cellspacing="0" class="table_form">
        <!--普通表单填写表格使用table_form-->
        <colgroup>
            <col style="width: 50px;"/>
            <col style="width: 100px;"/>
        </colgroup>
        <!--表单表格宽度控制使用colgroup，每个col对应下方的一个td，或者th，上下是对齐的-->
        <thead></thead>
        <!--表头-->
        <tbody>
        <!--表内容，th是蓝色字体，主要放字段名，td为字段内容-->
        <tr>
            <th >部门名称:</th>
            <td>
                <input type="text" name="departName" value="${dept.departName}">
            </td>
        </tr>
        </tbody>
    </table>
</form>
<div style="text-align: center; margin-top:15px;">
    <a href="javascript:void(0);" class="a_blue btn_op" id="saveDeptInfo"><em>保存</em></a>
</div>
<script type="text/javascript">
    //表单验证
    $("#deptInfoForm").validate({
        rules:{
            departName:{required:true, rangelength: [0,8]}
        }
    });
    $("#saveDeptInfo").click(function () {
        if(!$("#deptInfoForm").validate().form()){
            return false;
        }
        var url;
        if($("#deptInfo_id").val()!=null && $("#deptInfo_id").val()!=''){
            url = "${ctx}/dept/editDept";
        }else {
            url = "${ctx}/dept/addDept";
        }
        ajaxLoading();
        $.post(url,$("#deptInfoForm").serialize(),function (data) {
            ajaxLoadEnd();
            if(data.success){
                $.messager.alert('提示','操作成功');
                $('#personDialog').window("close");
                $("#deptList").datagrid('reload');
            }else {
                $.messager.alert('提示',data.mes);
            }
        });
    });
</script>
</body>
</html>
